import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class demo20 {
    public static void main(String[] args) throws IOException {
        try (FileReader fileReader = new FileReader("test.txt")) {
            while (true) {
                char[] chars = new char[5];
                //使用字符数组的话, 那read 返回的就是此次读取一共读取到的字符数, 不是对应的某个字符了
                int read = fileReader.read(chars);
                System.out.println("read: " + read);
                //转成对应的int 类型的read值
                if (read == -1) {
                    //读完了
                    return;
                }
                //将97转成字符就是a
                //读到几个就循环遍历打印数组中的几个字符, 切勿多打 少打
                for (int i = 0; i < read; i++) {
                    System.out.println(chars[i]);
                }

            }
        }
    }


}
